﻿using System;
using System.Linq.Expressions;

namespace Alex.Library.Specifications
{
    /// <summary>
    /// 1spec Or 2spec
    /// </summary>
    /// <typeparam name="T">any type</typeparam>
    public sealed class OrSpecification<T> : CompositeSpecification<T>
    {
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="front">the specification before "Or".</param>
        /// <param name="behind">the specification after "Or".</param>
        public OrSpecification(ISpecification<T> front, ISpecification<T> behind) : base(front, behind) { }

        /// <summary>
        /// get lambda expression's body
        /// </summary>
        /// <returns>lambda expression's body</returns>
        public override Expression<Func<T, bool>> GetExpression()
        {
            return this.Front.GetExpression().Or(this.Behind.GetExpression());
        }
    }
}
